import subprocess
import webbrowser
import pyperclip
import pyautogui
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from dir_objectName import dir_objectName

# 每次函数调用后暂停一秒
pyautogui.PAUSE = 1
# 启动自动防故障功能
pyautogui.FAILSAFE = True

volumes = []
for i in range(51, 59):
    url = "https://hellogithub.com/periodical/volume/{:0>2d}/" .format(i)

    chromeDriverPath = "D:\D00-软件&软件公司\D10网络工具\D11浏览器\chromedriver_win32/chromedriver.exe"
    #  浏览器启动
    browser = webdriver.Chrome(chromeDriverPath)
    #  将浏览器指向 
    browser.get(url)
    browser.maximize_window()
    time.sleep(3)
    # pyautogui.hotkey('ctrlleft', 'home')
    pyautogui.moveTo(x=374, y=165, duration=2.5)
    # pyautogui.press(['esc'])

    pyautogui.click()

    time.sleep(1)
    pyautogui.hotkey('ctrlleft', 'end')
    time.sleep(2)
    pyautogui.keyDown('shift')
    pyautogui.moveTo(x=1474, y=997, duration=2.5)
    pyautogui.click()
    pyautogui.keyUp('shift')
    pyautogui.hotkey('ctrlleft', 'c')
    # pyautogui.hotkey('altleft', 'tab')

    # close the browser tab
    browser.quit()
    subprocess.Popen(['start', 'HelloGitHub.md'], shell=True)
    time.sleep(3)
    pyautogui.hotkey('ctrlleft', 'end')
    pyautogui.press(['end', 'enter'])
    pyautogui.hotkey('ctrlleft', 'v')
    pyautogui.press(['end', 'enter'])
    
    time.sleep(5)
    pyautogui.hotkey('ctrlleft', 's')
    time.sleep(2)
    # webContent = pyperclip.paste()
    # with open("HelloGitHub.md", mode='a', encoding='utf8') as f:
    #     f.write(webContent)

































































